/* eslint-disable no-undef */

const fullScreen = () => {
  const el = document.documentElement
  const rfs = el.requestFullscreen
  // const rfs =
  //   el.requestFullscreen ||
  //   el.webkitRequestFullScreen ||
  //   el.mozRequestFullScreen ||
  //   el.msRequestFullscreen
  if (rfs) {
    // typeof rfs != "undefined" && rfs
    rfs.call(el)
  } else if (typeof window.ActiveXObject !== 'undefined') {
    // for IE，这里其实就是模拟了按下键盘的F11，使浏览器全屏
    const wscript = new window.ActiveXObject('WScript.Shell')
    if (wscript != null) {
      wscript.SendKeys('{F11}')
    }
  }
}

const exitFullScreen = () => {
  const el = document
  const cfs = el.exitFullscreen
  // const cfs =
  //   el.cancelFullScreen ||
  //   el.mozCancelFullScreen ||
  //   el.msExitFullscreen ||
  //   el.webkitExitFullscreen ||
  //   el.exitFullscreen
  if (cfs) {
    // typeof cfs != "undefined" && cfs
    cfs.call(el)
  } else if (typeof window.ActiveXObject !== 'undefined') {
    // for IE，这里和fullScreen相同，模拟按下F11键退出全屏
    const wscript = new window.ActiveXObject('WScript.Shell')
    if (wscript != null) {
      wscript.SendKeys('{F11}')
    }
  }
}

export { fullScreen, exitFullScreen }
